<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeFile="ViewNewsItem.aspx.cs" MaintainScrollPositionOnPostback="true" Inherits="WebControls.ViewNewsItem"
    Title="View comments" ValidateRequest="false" %>

<%@ Register Src="WebControls/NewsItem.ascx" TagName="NewsItem" TagPrefix="bn" %>
<%@ Register Src="WebControls/Comment.ascx" TagName="Comment" TagPrefix="bn" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <br />
    <br />
    <bn:NewsItem ID="niCurrent" runat="server" ShowCommentsLink="false" ShowFullText="true"
        EnableViewState="false" />
    <br />
    <h3>
        Comments:</h3>
    <asp:DataPager ID="dpCommentsUpper" PagedControlID="lvComments" runat="server" PageSize="5" QueryStringField="Page"
        EnableViewState="false">
        <Fields>
            <asp:NextPreviousPagerField FirstPageText="First" PreviousPageText="Previous" ShowPreviousPageButton="true"
                ShowFirstPageButton="true" ShowNextPageButton="false" ButtonCssClass="pager_next_previous" />
            <asp:NumericPagerField ButtonCount="10" NextPageText="..." PreviousPageText="..."
                CurrentPageLabelCssClass="pager_current_page" NumericButtonCssClass="pager_numeric" />
            <asp:NextPreviousPagerField LastPageText="Last" NextPageText="Next" ShowNextPageButton="true"
                ShowLastPageButton="true" ShowPreviousPageButton="false" ButtonCssClass="pager_next_previous" />
        </Fields>
    </asp:DataPager>
    <br />
    <br />
    <asp:ListView ID="lvComments" EnableViewState="False" runat="server" DataSourceID="odsComments"
        DataKeyNames="CommentID">
        <LayoutTemplate>
            <div id="itemPlaceholder" runat="Server">
            </div>
        </LayoutTemplate>
        <ItemTemplate>
            <bn:Comment ID="Comment" runat="server" Comment='<%# Container.DataItem %>' DeleteCommandName="Delete"
                EnableViewState="false" />
        </ItemTemplate>
        <EmptyDataTemplate>
            <h3>
                No comments yet.
            </h3>
        </EmptyDataTemplate>
    </asp:ListView>
    <asp:ObjectDataSource ID="odsComments" runat="server" TypeName="Mvp.NewsItems.ViewNewsItemPresenter"
        SelectMethod="SelectComments" SelectCountMethod="SelectCommentsCount" DeleteMethod="DeleteComment"
        EnablePaging="true" OnObjectCreating="odsComments_ObjectCreating" EnableViewState="false"></asp:ObjectDataSource>
    <asp:DataPager ID="dpCommentsLower" PagedControlID="lvComments" runat="server" PageSize="5" QueryStringField="Page"
        EnableViewState="false">
        <Fields>
            <asp:NextPreviousPagerField FirstPageText="First" PreviousPageText="Previous" ShowPreviousPageButton="true"
                ShowFirstPageButton="true" ShowNextPageButton="false" ButtonCssClass="pager_next_previous" />
            <asp:NumericPagerField ButtonCount="10" NextPageText="..." PreviousPageText="..."
                CurrentPageLabelCssClass="pager_current_page" NumericButtonCssClass="pager_numeric" />
            <asp:NextPreviousPagerField LastPageText="Last" NextPageText="Next" ShowNextPageButton="true"
                ShowLastPageButton="true" ShowPreviousPageButton="false" ButtonCssClass="pager_next_previous" />
        </Fields>
    </asp:DataPager>
    <br />
    <br />
    <asp:Panel ID="pnlCommentsEnabled" runat="server" EnableViewState="false" Visible="true">
        <br />
        <asp:LoginView ID="lvUsername" runat="server" EnableViewState="false">
            <LoggedInTemplate>
            </LoggedInTemplate>
            <AnonymousTemplate>
                Post as:
                <br />
                <asp:TextBox ID="txtNickname" runat="server" MaxLength="20" EnableViewState="false">Guest</asp:TextBox>
                <br />
            </AnonymousTemplate>
        </asp:LoginView>
        <br />
        <asp:Label ID="commentSubmitError" runat="server" Visible="False" Font-Size="Large"
            ForeColor="Red" EnableViewState="false">
            Warning! A new comment has been posted or the last comment has been deleted.<br />
        </asp:Label>
        <br />
        Post a comment:
        <br />
        <asp:TextBox ID="txtCommentText" runat="server" TextMode="MultiLine" Width="90%"
            Rows="5" EnableViewState="false"></asp:TextBox>
        <asp:RequiredFieldValidator ID="rfvComment" runat="server" ControlToValidate="txtCommentText"
            ErrorMessage="Cannot post empty comment" EnableViewState="false">*</asp:RequiredFieldValidator>
        <br />
        <br />
        <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click"
            EnableViewState="false" />
        <br />
    </asp:Panel>
    <asp:Panel ID="pnlCommentsDisabled" runat="server" Visible="false" EnableViewState="false">
        <h3>
            <asp:Label ID="lblCommentsStatus" runat="server" ForeColor="Red" EnableViewState="false"></asp:Label>
        </h3>
    </asp:Panel>
    <br />
    <br />
</asp:Content>
